<?php echo $header; ?><?php echo $column_left; ?>
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right"><a href="<?php echo $add; ?>" data-toggle="tooltip" title="<?php echo $button_add; ?>" class="btn btn-primary"><i class="fa fa-plus"></i></a> <a href="<?php echo $repair; ?>" data-toggle="tooltip" title="<?php echo $button_rebuild; ?>" class="btn btn-default"><i class="fa fa-refresh"></i></a>
      </div>
      <h1><?php echo $heading_title; ?></h1>
      <ul class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
        <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
        <?php } ?>
      </ul>
    </div>
  </div>
  <div class="container-fluid">
    <?php if ($error_warning) { ?>
    <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
      <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    <?php } ?>
    <?php if ($success) { ?>
    <div class="alert alert-success"><i class="fa fa-check-circle"></i> <?php echo $success; ?>
      <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    <?php } ?>
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-list"></i> <?php echo $text_list; ?></h3>
      </div>
      <div class="panel-body">
        <div class="well">
          <div class="row">
            <div class="col-sm-4">
              <div class="form-group">
                <label class="control-label" for="input-en_name"><?php echo $column_en_name; ?></label>
                <input type="text" name="filter_en_name" value="<?php echo $filter_en_name; ?>" placeholder="<?php echo $column_en_name; ?>" id="input-en_name" class="form-control" />
              </div>
              <div class="form-group">
                <label class="control-label" for="input-cn_name"><?php echo $column_cn_name; ?></label>
                <input type="text" name="filter_cn_name" value="<?php echo $filter_cn_name; ?>" placeholder="<?php echo $column_cn_name; ?>" id="input-cn_name" class="form-control" />
              </div>              
            </div>
            <div class="col-sm-4">
              <div class="form-group">
                <label class="control-label" for="input-name"><?php echo $column_name; ?></label>
                <input type="text" name="filter_name" value="<?php echo $filter_name; ?>" placeholder="<?php echo $column_name; ?>" id="input-name" class="form-control" />
              </div>
              <div class="form-group">
                <label class="control-label" for="input-tel"><?php echo $column_tel; ?></label>
                <input type="text" name="filter_tel" value="<?php echo $filter_tel; ?>" placeholder="<?php echo $column_tel; ?>" id="input-tel" class="form-control" />
              </div>
            </div>
            <div class="col-sm-4">
              <div class="form-group">
                <label class="control-label" for="input-email"><?php echo $column_email; ?></label>
                <input type="text" name="filter_email" value="<?php echo $filter_email; ?>" placeholder="<?php echo $column_email; ?>" id="input-email" class="form-control" />
              </div>
              <div class="form-group">
                <label class="control-label" for="input-status "><?php echo $column_status ; ?></label>
<!--                 <input type="text" name="filter_status " value="<?php echo $filter_status ; ?>" placeholder="<?php echo $column_status ; ?>" id="input-status " class="form-control" /> -->
                <select name="filter_status" id="input-status" class="form-control">
                  <option value="*"></option>
                  <?php if ($filter_status) { ?>
                    <?php foreach($status_all as $statu){ ?>
                      <option value="<?php echo $statu['id']; ?>" <?php if($filter_status == $statu['id']){ echo 'selected'; } ?> ><?php echo $statu['name_cn']; ?></option>
                    <?php } ?>
                  <?php }else{ ?>
                    <?php foreach($status_all as $statu){ ?>
                      <option value="<?php echo $statu['id']; ?>" ><?php echo $statu['name_cn']; ?></option>
                    <?php } ?>
                  <?php } ?>
                </select>                
              </div>
              <button type="button" id="button-filter" class="btn btn-primary pull-right"><i class="fa fa-search"></i> <?php echo $button_filter; ?></button>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-sm-6 text-left"><?php echo $pagination; ?></div>
          <div class="col-sm-6 text-right"><?php echo $results; ?></div>
        </div>
        <form action="<?php echo $delete; ?>" method="post" enctype="multipart/form-data" id="form-category">
          <div class="table-responsive">
            <table class="table table-bordered table-hover">
              <thead style="background-color: #f5f5f5;">
                <tr>
                  <!-- <td class="text-center"><?php echo $column_action; ?></td> -->
                  <td class="text-center" >序號</td>
                  <td class="text-center" width="2%"><?php echo $column_sysid; ?></td>
                  <td class="text-center" width="8%"><?php echo $column_en_name_1; ?></td>
                  <td class="text-center" width="8%"><?php echo $column_cn_name_1; ?></td>
                  <td class="text-center" width="8%"><?php echo $column_en_name_2; ?></td>
                  <td class="text-center" width="8%"><?php echo $column_cn_name_2; ?></td>
                  <td class="text-center" width="8%"><?php echo $column_en_name_3; ?></td>
                  <td class="text-center" width="8%"><?php echo $column_cn_name_3; ?></td>
                  <td class="text-center"><?php echo $column_sec_use; ?></td>
                  <td class="text-center"><?php echo $column_sec_use_other; ?></td>
                  <td class="text-center"><?php echo $column_sec_addr; ?></td>
                  <td class="text-center"><?php echo $column_sec_addr_other; ?></td>
                  <td class="text-center"><?php echo $column_name; ?></td>
                  <td class="text-center"><?php echo $column_email; ?></td>
                  <td class="text-center"><?php echo $column_tel; ?></td>
                  <td class="text-center" width="5%"><?php echo $column_addeddate; ?></td>
                  <td class="text-center"><?php echo $column_status; ?></td>
                </tr>
              </thead>
              <tbody>
                <?php if (isset($company_setup) && $company_setup) { ?>
                <?php foreach ($company_setup as $key => $customer) { ?>
                <tr>
                  <!-- <td class="text-center"><a href="<?php echo $customer['edit']; ?>" data-toggle="tooltip" title="<?php echo $button_edit; ?>" class="btn btn-primary"><i class="fa fa-pencil"></i></a></td> -->
                  <td class="text-center" ><?php echo $key+1; ?></td>
                  <td class="text-center"><a href="<?php echo $customer['edit']; ?>" ><?php echo $customer['sysid']; ?></a></td>
                  <td class="text-center"><a href="<?php echo $customer['edit']; ?>" ><?php echo $customer['en_name_1']; ?></a></td>
                  <td class="text-center"><a href="<?php echo $customer['edit']; ?>" ><?php echo $customer['cn_name_1']; ?></a></td>
                  <td class="text-center"><?php echo $customer['en_name_2']; ?></td>
                  <td class="text-center"><?php echo $customer['cn_name_2']; ?></td>
                  <td class="text-center"><?php echo $customer['en_name_3']; ?></td>
                  <td class="text-center"><?php echo $customer['cn_name_3']; ?></td>
                  <td class="text-center"><?php echo $customer['sec_use']; ?></td>
                  <td class="text-center"><?php echo $customer['sec_use_other']; ?></td>
                  <td class="text-center"><?php echo $customer['sec_addr']; ?></td>
                  <td class="text-center"><?php echo $customer['sec_addr_other']; ?></td>
                  <td class="text-center"><?php echo $customer['name']; ?></td>
                  <td class="text-center"><?php echo $customer['email']; ?></td>
                  <td class="text-center"><?php echo $customer['tel']; ?></td>
                  <td class="text-center"><?php echo $customer['addeddate']; ?></td>
                  <td class="text-center"><?php echo $customer['status']; ?></td>


                  
                </tr>
                <?php } ?>
                <?php } else { ?>
                <tr>
                  <td class="text-center" colspan="17"><?php echo $text_no_results; ?></td>
                </tr>
                <?php } ?>
              </tbody>
              <tfoot style="background-color: #f5f5f5;font-weight: 700;">
                <tr>
                  <!-- <td class="text-center"><?php echo $column_action; ?></td> -->
                  <td class="text-center" >序號</td>
                  <td class="text-center" width="2%"><?php echo $column_sysid; ?></td>
                  <td class="text-center"><?php echo $column_en_name_1; ?></td>
                  <td class="text-center"><?php echo $column_cn_name_1; ?></td>
                  <td class="text-center"><?php echo $column_en_name_2; ?></td>
                  <td class="text-center"><?php echo $column_cn_name_2; ?></td>
                  <td class="text-center"><?php echo $column_en_name_3; ?></td>
                  <td class="text-center"><?php echo $column_cn_name_3; ?></td>
                  <td class="text-center"><?php echo $column_sec_use; ?></td>
                  <td class="text-center"><?php echo $column_sec_use_other; ?></td>
                  <td class="text-center"><?php echo $column_sec_addr; ?></td>
                  <td class="text-center"><?php echo $column_sec_addr_other; ?></td>
                  <td class="text-center"><?php echo $column_name; ?></td>
                  <td class="text-center"><?php echo $column_email; ?></td>
                  <td class="text-center"><?php echo $column_tel; ?></td>
                  <td class="text-center"><?php echo $column_addeddate; ?></td>
                  <td class="text-center"><?php echo $column_status; ?></td>
                </tr>
              </tfoot>
            </table>
          </div>
        </form>
        <div class="row">
          <div class="col-sm-6 text-left"><?php echo $pagination; ?></div>
          <div class="col-sm-6 text-right"><?php echo $results; ?></div>
        </div>
      </div>
    </div>
  </div>
</div>
  <script type="text/javascript"><!--
$('#button-filter').on('click', function() {
  var url = 'index.php?route=hk/company_setup&token=<?php echo $token; ?>';

  var filter_en_name = $('input[name=\'filter_en_name\']').val();

  if (filter_en_name) {
    url += '&filter_en_name=' + encodeURIComponent(filter_en_name);
  }

  var filter_cn_name = $('input[name=\'filter_cn_name\']').val();

  if (filter_cn_name) {
    url += '&filter_cn_name=' + encodeURIComponent(filter_cn_name);
  }

  var filter_name = $('input[name=\'filter_name\']').val();

  if (filter_name) {
    url += '&filter_name=' + encodeURIComponent(filter_name);
  }

  var filter_tel = $('input[name=\'filter_tel\']').val();

  if (filter_tel) {
    url += '&filter_tel=' + encodeURIComponent(filter_tel);
  }

  var filter_email = $('input[name=\'filter_email\']').val();

  if (filter_email) {
    url += '&filter_email=' + encodeURIComponent(filter_email);
  }

  var filter_status = $('select[name=\'filter_status\']').val();
console.log(filter_status);
  if (filter_status) {
    url += '&filter_status=' + encodeURIComponent(filter_status);
  }


  location = url;
});
//--></script>
<script type="text/javascript"><!--
$('input[name=\'filter_company_eng_name\']').autocomplete({
  'source': function(request, response) {
    $.ajax({
      url: 'index.php?route=project/project_customer/autocomplete&token=<?php echo $token; ?>&filter_company_eng_name=' +  encodeURIComponent(request),
      dataType: 'json',
      success: function(json) {
        response($.map(json, function(item) {
          return {
            label: item['company_eng_name'],
            value: item['company_eng_name']
          }
        }));
      }
    });
  },
  'select': function(item) {
    $('input[name=\'filter_company_eng_name\']').val(item['label']);
  }
});

$('input[name=\'filter_company_chn_name\']').autocomplete({
  'source': function(request, response) {
    $.ajax({
      url: 'index.php?route=project/project_customer/autocomplete&token=<?php echo $token; ?>&filter_company_chn_name=' +  encodeURIComponent(request),
      dataType: 'json',
      success: function(json) {
        response($.map(json, function(item) {
          return {
            label: item['company_chn_name'],
            value: item['company_chn_name']
          }
        }));
      }
    });
  },
  'select': function(item) {
    $('input[name=\'filter_company_chn_name\']').val(item['label']);
  }
});
//--></script>
<?php echo $footer; ?>